<%@ Page Title="Users" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" 
	Inherits="System.Web.Mvc.ViewPage<IEnumerable<User>>" %>
<%@ Import Namespace="MindMelder.Core" %>
<%@ Import Namespace="MindMelder.Web.Controllers" %>

<asp:Content ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <h2>Users</h2>

    <% if (ViewContext.TempData["message"] != null){ %>
        <p><%= ViewContext.TempData["message"]%></p>
    <% } %>

    <table>
		<%
		foreach (User user in ViewData.Model) { %>
			<tr>
				<td>
					<%= Html.ActionLink<UsersController>(c => c.Show(user.Id), user.FullName,
						new { title = user.Skills.Count > 0 ?
									  user.Skills.Select(s => s.Name).Aggregate("Skilled in ", (curr, item) => curr + " " + item)
									  : "Skills unknown"
							})%>
				</td>
			</tr>
		<%} %>
    </table>
</asp:Content>
